package com.yunbiao.ybbusstopplate.ui.fragment

import android.util.Log
import com.blankj.utilcode.util.UiMessageUtils
import com.yunbiao.ybbusstopplate.R
import com.yunbiao.ybbusstopplate.base.BaseFragment
import kotlinx.android.synthetic.main.fragment_leshan_line_info.*

class ThreeAreaLineInfoFragment  : BaseFragment(), UiMessageUtils.UiMessageCallback {

    companion object {
        const val EVENT_LINE_NAME : Int = 111
        const val EVENT_LINE_START : Int = 112
        const val EVENT_LINE_END : Int = 113

        fun getInstance():ThreeAreaLineInfoFragment{
            val threeAreaLineInfoFragment = ThreeAreaLineInfoFragment()
            return threeAreaLineInfoFragment
        }
    }

    override fun getViewId(): Int {
        return R.layout.fragment_three_area_line_info;
    }

    override fun initData() {
        UiMessageUtils.getInstance().addListener(this)
    }

    override fun initListener() {
        TODO("Not yet implemented")
    }

    private val TAG = "ThreeAreaLineInfoFragment"
    override fun handleMessage(p0: UiMessageUtils.UiMessage) {
        Log.d("info","路信息：" + p0)
        when (p0.id) {
            LeshanLineInfoFragment.EVENT_LINE_NAME -> {
                var content = p0.`object`.toString()
                if(content.contains("路")){
                    content = content.replace("路","")
                }
                tv_line_name.text = content + "路"
            }
            LeshanLineInfoFragment.EVENT_LINE_START -> {
                tv_site_start.text = p0.`object`.toString()
            }
            LeshanLineInfoFragment.EVENT_LINE_END -> {
                tv_site_end.text = p0.`object`.toString()
            }
            else -> {}
        }
    }
}